<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="js/jquery.uploadify.min.js"></script>
<script type="text/javascript">
 var picIndex=1;
 $.format = function (source, params) {
	if (arguments.length == 1)
		return function () {
			var args = $.makeArray(arguments);
			args.unshift(source);
			return $.format.apply(this, args);
		};
	if (arguments.length > 2 && params.constructor != Array) {
		params = $.makeArray(arguments).slice(1);
	}
	if (params.constructor != Array) {
		params = [params];
	}
	$.each(params, function (i, n) {
		source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
	});
	return source;
};
function fileError(file, errorCode, errorMsg){
	switch(errorCode) {
		case -100:
			alert("上传的文件数量已经超出系统限制！");
			break;
		case -110:
			alert("文件 ["+file.name+"] 大小超出系统限制！");
			break;
		case -120:
			alert("文件 ["+file.name+"] 大小异常！");
			break;
		case -130:
			alert("文件 ["+file.name+"] 类型不正确！");
			break;
	}
}
$(function() {
<?php	
$loginuserid        = getcvar('loginuserid',1);       //用户ID
$loginusername      = getcvar('loginusername',1);     //用户名

?>
	$('#img_upload').uploadify({
            'formData'      	: {
			'classid' : '<?=$classid?>',
			'filepass':'<?=$newstime?>',
			'username':'<?=$loginusername?>',
			'userid':'<?=$loginuserid?>'			
			
			},
            'swf'      : '../extend/uploadify/uploadify.swf',
            'uploader' : '../extend/uploadify/uploadify.php',
            //在浏览窗口底部的文件类型下拉菜单中显示的文本
            'buttonCursor':'hand',
            'buttonImage':'../extend/uploadify/button_images.png','width':99,'height':25,
            'fileTypeExts':'*.jpg;*.png;*.gif',
            //上传文件的大小限制
            'fileSizeLimit':'10MB',
            //上传数量
            'multi':true,
            'queueSizeLimit' : 100,
            //文件较多，时间设大一些
            'successTimeout':120,
            //返回一个错误，选择文件的时候触发
            'onSelectError':fileError,
            //检测FLASH失败调用
            'onFallback':function(){
                alert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。");
            },
            //上传到服务器，服务器返回相应信息到data里
            'onUploadSuccess':function(file, data, response){
			
				var obj=jQuery.parseJSON(data);
				if(obj.error){
                    alert("上传出现错误！");
                }else{
                    addPicLine(picIndex);
                    $("#mbigpic"+picIndex).val(obj.big);
                    $("#mpicname"+picIndex).val(obj.name);
					if(obj.small){
						$("#msmallpic"+picIndex).val(obj.small);
						$("#preImg"+picIndex).attr("src",obj.small);
					}else{
						$("#msmallpic"+picIndex).val(obj.big);
						$("#preImg"+picIndex).attr("src",obj.big);
					}
                    picIndex++;

                }
					
            }, 
			'onUploadStart': function (file) {
                    $("#img_upload").uploadify("settings", "formData", {'mrnd':'<?=$mrnd?>',
					'addwater':$('#addwater').is(':checked'),
					'mcreatespic':$('#mcreatespic').is(':checked'),
			'mcreatespicwidth':$('#mcreatespicwidth').val(),
			'mcreatespicheight':$('#mcreatespicheight').val()});
                    //在onUploadStart事件中，也就是上传之前，把参数写好传递到后台。
            }

        });
	<?php
    if($ecmsfirstpost==1)
    {
	?>
	picIndex=1;
	<?php
    }
    else
    {
	$morepicpath="";
	$morepicnum=0;
	if($r[morepic])
    	{
    		$r[morepic]=stripSlashes($r[morepic]);
    		//地址
    		$j=0;
    		$pd_record=explode("\r\n",$r[morepic]);
    		for($i=0;$i<count($pd_record);$i++)
    		{
			$j=$i+1;
    			$pd_field=explode("::::::",$pd_record[$i]);
			?>
					addPicLine(<?=$j?>);
                    $("#msmallpic<?=$j?>").val("<?=$pd_field[0]?>");
                    $("#mbigpic<?=$j?>").val("<?=$pd_field[1]?>");
                    $("#mpicname<?=$j?>").val("<?=$pd_field[2]?>");
                    $("#preImg<?=$j?>").attr("src","<?=$pd_field[1]?>");
                    picIndex++;
			<?php 
    		}
    		$morepicnum=$j;
    	}
    }
    ?>

});
</script>

<body>
	<div id="img_upload" class="uploadify" >
		<div id="img_upload-button" class="uploadify-button " style="text-indent: -9999px; height: 25px; line-height: 25px; width: 99px; background-image: url(http://hao.franzsandner.com/e/extend/uploadify/button_images.png);"><span class="uploadify-button-text">SELECT FILES</span></div>
	</div>
	<div id="img_upload-queue" class="uploadify-queue"></div>



</body>